﻿using System.Collections.Generic;
using Orchard;
using Orchard.ContentManagement;
using Orchard.Localization;
using Orchard.UI.Admin.Notification;
using Orchard.UI.Notify;
using TissotWeb.GoogleMaps.Models;

namespace TissotWeb.GoogleMaps {
	public class MissingMapsSettingsBanner : INotificationProvider {
		private readonly IOrchardServices _orchardServices;

        public MissingMapsSettingsBanner(IOrchardServices orchardServices)
        {
			_orchardServices = orchardServices;
			T = NullLocalizer.Instance;
		}

		public Localizer T { get; set; }

		public IEnumerable<NotifyEntry> GetNotifications() {
			var googleMapsSettings = _orchardServices.WorkContext.CurrentSite.As<GoogleMapSettingsPart>();
			if (googleMapsSettings == null || string.IsNullOrWhiteSpace(googleMapsSettings.GoogleMapApiKey)) {
				yield return new NotifyEntry { Message = T("The Google Maps API KEY need to be configured."), Type = NotifyType.Warning };
			}
		}
	}
}